home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- #include <vcl\vcl.h>
- #pragma hdrstop
-
- #include "FMain.h"
- //---------------------------------------------------------------------------
- #pragma link "UPTFrame"
- #pragma link "UPTShellControls"
- #pragma link "UPTTreeList"
- #pragma resource "*.dfm"
- TFrmMain *FrmMain;
- //---------------------------------------------------------------------------
- /*
- The technique used to determine which nodes are "Computer" nodes is find which image is
- used for computers and simple check a node's image against that value. It should be
- possible to use the SHGetDataFromIDList function to check what type a node is, but
- that function seems very unreliable.
- */
- __fastcall TFrmMain::TFrmMain(TComponent* Owner)
- : TForm(Owner)
- {
- try {
- char sz[MAX_COMPUTERNAME_LENGTH+1];
- DWORD siz = sizeof(sz);
- GetComputerName( sz, &siz );
- if (strlen(sz) == 0)
- throw new Exception( "This computer is not present on the network." );
- FComputerIndex = ShellGetIconIndexFromPath("\\\\"+AnsiString(sz),0);
- }
- catch( Exception* e ) {
- Application->ShowMainForm = false;
- Application->HandleException(e);
- Application->Terminate();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmMain::PTShellTree1Change(TObject *Sender, TTreeNode *Node)
- {
- if (Node->ImageIndex == FComputerIndex)
- SetFrameText( Node->Text );
- else
- SetFrameText( "" );
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmMain::SetFrameText( AnsiString aName )
- {
- if (aName.Length() == 0) {
- CompLabel->Caption = "<Not a computer>";
- CompLabel->Color = clRed;
- }
- else {
- CompLabel->Caption = aName;
- CompLabel->Color = clGreen;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmMain::Exit1Click(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------